Ext.namespace('TaxonTagger');
TaxonTagger.Properties = function(config){

	editable: true;

 	this.comboEncoding = new Ext.form.ComboBox({
			fieldLabel: 'comboEncoding'
		,	name: 'comboEncoding'
		,	allowBlank: false
		,	store: ['UTF-8', 'UTF-16', 'Latin1', 'Windows1252']
		,	typeAhead: true
		,	mode: 'local'
		,	triggerAction: 'all'
		,	emptyText:'-- Select encoding--'
		,	selectOnFocus: true
		,	listeners: {
				change: function(){
					if (Ext.isEmpty(this.value)) {
						//notice
					}
				}
		}
 	});

 	this.comboTerminatedBy = new Ext.form.ComboBox({
			fieldLabel: 'comboTerminatedBy'
		,	name: 'comboTerminatedBy'
		,	allowBlank: false
		,	store: ['\\r\\n', '\\n', '\\r']
		,	typeAhead: true
		,	mode: 'local'
		,	triggerAction: 'all'
		,	emptyText:'-- Select Type--'
		,	selectOnFocus: true
		,	listeners: {
				change: function(){
					if (Ext.isEmpty(this.value)) {
						//notice
					}
				}
			}
	});

 	this.comboFieldDelimiter = new Ext.form.ComboBox({
			fieldLabel: 'comboFieldDelimiter'
		,	name: 'comboFieldDelimiter'
		,	allowBlank: false
		,	store: ['\\t', ',', ';', '|', ']']
		,	typeAhead: true
		,	mode: 'local'
		,	triggerAction: 'all'
		,	emptyText:'-- Select Type--'
		,	selectOnFocus: true
		,	listeners: {
				change: function(){
					if (Ext.isEmpty(this.value)) {
						//notice
					}
				}
			}
	});

	this.comboEnclosedBy = new Ext.form.ComboBox({
			fieldLabel: 'comboEnclosedBy'
		,	name: 'comboEnclosedBy'
		,	allowBlank: false
		,	store: ['(none)', '"', "'"]
		,	typeAhead: true
		,	mode: 'local'
		,	triggerAction: 'all'
		,	emptyText:'-- Select Type--'
		,	selectOnFocus: true
		,	listeners: {
				change: function(){
					if (Ext.isEmpty(this.value)) {
					//notice
					} 
				}
			}
	});
	
	Ext.apply(this, config, {
			source: Config.delimiter.delimiterGrid
		,	listeners: {
				beforeedit: function (e) {
					return( this.editable );
					switch (e.record.id) {
						default:
						return true;
					}
				}
			}
		,	viewConfig: {
					forceFit: true
				,	scrollOffset: 2
			}
		,	customEditors: {
					'File Encoding': new Ext.grid.GridEditor(this.comboEncoding)
				,	'Line ending': new Ext.grid.GridEditor(this.comboTerminatedBy)
				,	'Line ending': new Ext.grid.GridEditor(this.comboTerminatedBy)
				,	'Field Delimiter': new Ext.grid.GridEditor(this.comboFieldDelimiter)
				,	'Fields enclosed by': new Ext.grid.GridEditor(this.comboEnclosedBy)                
			}
	});
	
	TaxonTagger.Properties.superclass.constructor.call(this, config);

}    

Ext.extend(TaxonTagger.Properties, Ext.grid.PropertyGrid, {

		setCsv: function(){
			var tConfig = Ext.decode(localStorage.getItem("settings")) || Config;
			this.setSource({
					'File Encoding': tConfig["delimiter"]["setCsv"]["File Encoding"]
				,	'Field Delimiter': tConfig["delimiter"]["setCsv"]["Field Delimiter"]
				,	'Fields enclosed by': tConfig["delimiter"]["setCsv"]["Fields enclosed by"]
				,	'Line ending': tConfig["delimiter"]["setCsv"]["Line ending"]
				,	'Ignore header row':tConfig["delimiter"]["setCsv"]["Ignore header row"]
			});
			this.editable = true;
		}

	,	setTab: function(){
			var tConfig = Ext.decode(localStorage.getItem("settings")) || Config;
			this.setSource({
					'File Encoding': tConfig["delimiter"]["setTab"]["File Encoding"]
				,	'Field Delimiter': tConfig["delimiter"]["setTab"]["Field Delimiter"]
				,	'Fields enclosed by': tConfig["delimiter"]["setTab"]["Fields enclosed by"]
				,	'Line ending': tConfig["delimiter"]["setTab"]["Line ending"]
				,	'Ignore header row':tConfig["delimiter"]["setTab"]["Ignore header row"]
			});
			this.editable = true;
		}

	,	setCustom: function(){
			var tConfig = Ext.decode(localStorage.getItem("settings")) || Config;
			this.setSource({
					'File Encoding': tConfig["delimiter"]["setCustom"]["File Encoding"]
				,	'Field Delimiter': tConfig["delimiter"]["setCustom"]["Field Delimiter"]
				,	'Fields enclosed by': tConfig["delimiter"]["setCustom"]["Fields enclosed by"]
				,	'Line ending': tConfig["delimiter"]["setCustom"]["Line ending"]
				,	'Ignore header row':tConfig["delimiter"]["setCustom"]["Ignore header row"]
			});
			this.editable = true;
		}	

});